import request from '@/utils/request';

const MESSAGE_BASE_URL = '/admin/sms/event';

const EventAPI = {
  /**
   * 手动触发指定批次的截止提醒短信
   *
   * @param batchId 指定批次id
   * @param batchName 批次名称
   * @param deadline 截止时间
   * @returns
   */
  addMessage(batchId: string, data?: any) {
    return request({
      url: `${MESSAGE_BASE_URL}/trigger/deadline/${batchId}`,
      method: 'post',
      data: data,
    });
  },
  /**
   * 手动触发指定批次的发布短信通知
   *
   * @param batchId 指定批次id
   * @param batchName 批次名称
   * @param deadline 截止时间
   * @returns
   */
  publishMessage(batchId: string, data?: any) {
    return request({
      url: `${MESSAGE_BASE_URL}/trigger/batch/${batchId}`,
      method: 'post',
      data: data,
    });
  },
  /**
   * 手动发布业务事件
   *
   * @param eventType 事件类型
   * @param businessId 业务ID
   * @returns
   */
  publishBusiness(eventType?: string, businessId?: any) {
    return request({
      url: `${MESSAGE_BASE_URL}/publish?eventType=${eventType}&businessId=${businessId}`,
      method: 'post',
    });
  },
  /**
   * 获取未处理事件数量
   *
   * @returns
   */
  getUnprocessed() {
    return request({
      url: `${MESSAGE_BASE_URL}/unprocessed-count`,
      method: 'get',
    });
  },
  /**
   * 获取最近事件列表
   *
   * @returns
   */
  getRecentList() {
    return request({
      url: `${MESSAGE_BASE_URL}/recent`,
      method: 'get',
    });
  },
};

export default EventAPI;
